﻿using ConfExpert.Forms.Base;
using System;
using System.IO;
using System.Windows.Forms;

namespace ConfExpert.Forms.Sistem
{
    public partial class Coverage : XForm
    {
        public Coverage()
        {
            InitializeComponent();
        }

        BindingSource bs;
        //string Path = @"C:\CodePlex\confexpert";
        string Path = @"D:\";
        private void Coverage_Load(object sender, EventArgs e)
        {
            
            TAM.ProjectTableAdapter = new Datasets.MyDataTableAdapters.ProjectTableAdapter();
            bs = new BindingSource(ds, "Project");
            AddBsToList(bs);
            btnKaydet.ItemClick += btnKaydet_ItemClick;

            string[] fileEntries = Directory.GetFiles(Path, "*.sql", SearchOption.TopDirectoryOnly);
            foreach (string fileName in fileEntries)
            {
                FileInfo fi = new FileInfo(fileName);

                if (fi.Name == "Excluded.cs")
                    continue;

                if (!fi.Name.Contains("_") &&
                    !fi.Name.Contains("Designer.cs"))
                {
                    StreamReader streamReader = new StreamReader(fileName);
                    string text = streamReader.ReadToEnd();

                    ConfExpert.Datasets.MyData.ProjectRow r = ds.Project.NewProjectRow();
                    //r.icerik = text;
                    //r.dosya = fi.FullName;
                    ds.Project.AddProjectRow(r);

                    streamReader.Close();
                }
            }
        }

        void btnKaydet_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            Save();
        }
    }

}